home *** CD-ROM | disk | FTP | other *** search
- /*
- CGEView.cpp
-
- Demo cross-platform view class for MacHack '97
-
- Al Evans
-
- 6/12/97
-
- */
-
- #include "CGEView.h"
- #include "CDemoWindow.h"
- #include "DemoConversions.h"
- #include "DemoGraphicTypes.h"
- #include "GEWmgr.h"
- #include "UnivPictLoader.h"
- #include "reschain.h"
-
-
- CGEView::CGEView(CDemoWindow *owner, int32 viewResID)
- :mOwner(owner), mGEWorld(nil)
- {
- // Read view definition from resource
- void* vLayoutRes = GetResourcePtr('Vnfo', viewResID);
- assert( vLayoutRes );
- ViewLayout layout = *(ViewLayout *) vLayoutRes;
- ReleaseResourcePtr( vLayoutRes );
-
- SwapIfRequired(&layout);
-
- mGEWorld = NewGEWorld( (GrafPtr) mOwner->GetSystemWindow(),
- &mOwner->GetWindRect(), scaleOneToOne, mOwner->GetPalette());
- if (mGEWorld) {
- (void) AddToWorldList(mGEWorld, true);
-
- // Set Graphic Elements to use "universal pictures" instead of PICTs
- mGEWorld->defaultLoader = LoadUnivPictElement;
-
- // If this were a real program, we'd resize the window here to
- // layout.viewSize
-
- if (layout.viewBkgID != 0)
- MakeNewBackground(mGEWorld, layout.viewBkgID);
- if (layout.viewBouncerID != 0)
- MakeNewBouncer(mGEWorld, layout.viewBouncerID);
- if (layout.viewBtnID != 0)
- MakeNewBtn(mGEWorld, layout.viewBtnID);
- }
-
-
- }
-
- CGEView::~CGEView()
- {
- if (mGEWorld)
- DisposeGEWorld(mGEWorld);
- }
-
- void CGEView::Activate(Boolean activateIt)
- {
- if (mGEWorld)
- ActivateWorld(mGEWorld, activateIt);
- }
-
- void CGEView::Idle()
- {
- if (mGEWorld)
- Update1GEWorld(mGEWorld, false);
- }
-
- void CGEView::Draw()
- {
- if (mGEWorld) DoWorldUpdate(mGEWorld, true);
- }
-
- void CGEView::HandleMouseDown(Point mousePt)
- {
- if (mGEWorld) {
- #if TARGET_IS_WIN95
- ::ClientToScreen(mOwner->GetSafeHwnd(), &mousePt.WinPoint);
- #endif
- MouseDownInSensor(mGEWorld, mousePt);
- }
- }
-
-